// import Mock from 'mockjs'
import { nanoid } from 'nanoid'

let user = [
  {
    id: nanoid(),
    email: '2283341909@qq.com',
    password: '123'
  }
]

export const register = data => {
  let body = JSON.parse(data.body)
  user.push({
    id: nanoid(),
    email: body.email,
    password: body.password
  })
  return {
    code: 200
  }
}

export const ishaveemail = data => {
  console.log(data)
}

export const login = data => {
  let body = JSON.parse(data.body)
  let flag = user.some(item => {
    return item.password === body.password && item.email === body.email
  })
  if (flag) {
    return {
      code: 200,
      data: {
        stuts: 'ok'
      }
    }
  } else {
    return {
      code: 403,
      data: {
        content: 'no user'
      }
    }
  }
}
